Add .NET passwordless, Python connection-string, and Go CRUD initial samples#3
Conversation
- dotnet/001-connect-passwordless: .NET 8 passwordless auth via DefaultAzureCredential - python/002-connect-connection-string: Python connection string auth with python-dotenv - go/101-create-item: Go full CRUD sample with key-based auth Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: seesharprun <5067401+seesharprun@users.noreply.github.com>
seesharprun
left a comment
There was a problem hiding this comment.
Can we turn .NET into a file-based app? https://learn.microsoft.com/en-us/dotnet/core/sdk/file-based-apps
…tignore Co-authored-by: seesharprun <5067401+seesharprun@users.noreply.github.com>
…ectives) Co-authored-by: seesharprun <5067401+seesharprun@users.noreply.github.com>
Done in 975be28. Removed Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…OSMOS_KEY Co-authored-by: seesharprun <5067401+seesharprun@users.noreply.github.com>
|
@copilot, investigate why the go.sum check and the .NET check failed |
…pdate .NET workflow for file-based apps Co-authored-by: seesharprun <5067401+seesharprun@users.noreply.github.com>
Fixed in a373589. Three root causes:
|
seesharprun
left a comment
There was a problem hiding this comment.
Can you make all README files lowercase readme.md?
seesharprun
left a comment
There was a problem hiding this comment.
Please don't modify the validation workflow
…anges; update structure check to readme.md Co-authored-by: seesharprun <5067401+seesharprun@users.noreply.github.com>
Done in cfa4280 — renamed
Reverted the .NET section changes in cfa4280 — |
Signed-off-by: Sidney Andrews <sidandrews@microsoft.com>
seesharprun
left a comment
There was a problem hiding this comment.
The PR currently uses .env.example files to instruct users how to configure environment variables for code samples. The goal is to reduce friction, reduce extra files, and minimize complexity while remaining clear and safe for users.
Key Points
- Inline shell commands (
exporton macOS/Linux,$Env:in PowerShell) set environment variables only for the current terminal session. - These commands do not persist, do not modify user profiles, and do not affect system-wide settings.
- Persistent approaches (
setx, editing.bashrc/.zshrc) should be avoided in samples. - Inline setup avoids extra files, avoids secrets on disk, and is the lowest-friction option for public samples.
- GitHub supports GFM admonitions, which are appropriate when they prevent user confusion.
#1 Recommendation (Preferred Pattern)
Use inline environment variable setup instructions in the README, with a short IMPORTANT note clarifying non-persistence.
Recommended README Pattern
> [!IMPORTANT]
> These environment variables are set **only for the current terminal session** and do **not persist** after you close the window.
### macOS / Linux
```bash
export COSMOS_ENDPOINT="https://..."
export COSMOS_KEY="..."
python app.py
```
### Windows (PowerShell)
```powershell
$Env:COSMOS_ENDPOINT="https://..."
$Env:COSMOS_KEY="..."
python app.py
```
Why this approach
- No extra files (
.env.examplenot required) - No secrets written to disk
- Clear, explicit, copy/paste friendly
- Easy to undo (close terminal)
- Reduces user confusion while keeping docs lightweight
When to consider alternatives
- Use managed identity / default credentials for passwordless code samples only
…n-dotenv, update all readmes Co-authored-by: seesharprun <5067401+seesharprun@users.noreply.github.com>
Done in ea3ff90:
|
…uration Co-authored-by: seesharprun <5067401+seesharprun@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds new Azure Cosmos DB for NoSQL samples across Python, Go, and .NET, plus language-scoped .gitignore files, to help developers quickly connect/authenticate and perform basic data operations.
Changes:
- Add a Python key-auth connection sample (endpoint + key) with a minimal
requirements.txt. - Add a Go CRUD sample using
azcosmos(database/container creation + item operations). - Add a .NET passwordless sample using
DefaultAzureCredentialand user-secrets, and introduce language-level.gitignorefiles.
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/002-connect-connection-string/requirements.txt | Pins azure-cosmos dependency for the Python sample |
| python/002-connect-connection-string/readme.md | Run instructions + description for the Python sample |
| python/002-connect-connection-string/app.py | Python implementation: connect, create DB/container, upsert and query items |
| python/.gitignore | Adds Python-specific ignore rules |
| go/101-create-item/readme.md | Run instructions + CRUD description for the Go sample |
| go/101-create-item/main.go | Go implementation: connect, create DB/container, upsert/read/replace/delete item |
| go/101-create-item/go.mod | Go module definition + dependencies |
| go/101-create-item/go.sum | Go dependency checksums |
| go/.gitignore | Adds Go-specific ignore rules |
| dotnet/001-connect-passwordless/readme.md | Setup/run guide for passwordless .NET sample |
| dotnet/001-connect-passwordless/Program.cs | .NET file-based app using user-secrets + DefaultAzureCredential |
| dotnet/.gitignore | Adds .NET/Visual Studio ignore rules |
| .gitignore | Adds basic repo-wide ignores for macOS + JetBrains |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| created = container.upsert_item(body=new_item) | ||
| print(f"Upserted item: {created['id']}") | ||
|
|
||
| query = "SELECT * FROM products p WHERE p.category = @category" |
| # Connect to Azure Cosmos DB for NoSQL — Key Auth (Python) | ||
|
|
||
| This sample demonstrates how to authenticate to Azure Cosmos DB for NoSQL using an **account key**. This is a quick way to get started, especially for local development and testing. |
| _, err = containerClient.UpsertItem(ctx, pk, itemBytes, nil) | ||
| if err != nil { | ||
| log.Fatalf("failed to upsert item: %v", err) | ||
| } | ||
| fmt.Printf("Upserted item: %s\n", product.ID) |
|
|
||
| | Operation | Description | | ||
| |-----------|-------------| | ||
| | **Create** | Inserts a new `Product` item into the `products` container | |
| toolchain go1.24.13 | ||
|
|
dotnet/.gitignore,python/.gitignore,go/.gitignore.gitignoredotnet/001-connect-passwordlessto .NET 10 file-based appCosmosClient(url, credential)readme.md.env.examplefiles; droppython-dotenv; use inline env var setup in all readmesdotnet user-secrets: addUserSecretsIdproperty +Microsoft.Extensions.Configuration.UserSecrets@10.*package, read config viaIConfigurationBuilder.AddUserSecrets<Program>(), updatereadme.mdwithdotnet user-secrets set --file Program.csinstructionsOriginal prompt
Finally, delegate to a third agent the job of building the first code samples. I want a .NET passwordless samples, a Python connection-string+key sample, and a Go CRUD sample.
[Chronological Review: The conversation began with the user requesting a review of a user story and a Teams chat to develop a game plan for a draft iteration of a monorepo. The user then defined a numbering standard for samples in the repository, specifying categories and their respective number ranges. The user later requested to break the work into smaller pieces for incremental merging and to delegate tasks to a cloud agent. The user provided a list of sample repositories for reference and emphasized the importance of planning for future implementations. The conversation continued with the user specifying the structure of the repository, including the README file's content and the need for a validation workflow. The user requested to simplify the project plan and limit the number of examples per category. The user concluded by asking to add the project plan to the README file and delegate the creation of the validation workflow to a separate agent.][Intent Mapping:
[Technical Inventory:
/nosql/*subfolder, use languages as root subfolders, limit examples to 2-3 per category.][Code Archaeology:
[Progress Assessment:
[Context Validation: All critical information for continuation is captured, including the need for a structured project plan and validation workflow.]
[Recent Commands Analysis:
1. Conversation Overview: - Primary Objectives: The user aims to create a structured monorepo for Azure Cosmos DB samples, define a numbering standard for samples, and implement a validation workflow. - Session Context: The conversation has progressed from initial planning to defining repository structure and validation needs, with a focus on incremental implementation. - User Intent Evolution: The user has shifted from broad planning to specific implementation details, emphasizing the importance of a structured approach and validation.- Technical Foundation:
- Azure Cosmos DB: Central technology for the samples repository.
- GitHub: Platform for version control and collaboration.
- Cloud Agents: Intended for task delegation and automation.
- Codebase Status:
- README.md:
- Purpose: To document the project plan and repository structure.
- Current State: Pending updates to include the project plan and validation workflow.
- Key Code Segments: Project plan details to be added.
- Dependencies: Relates to overall repository structure and validation processes.
- Problem Resolution:
- Issues Encountered: Need for a structured approach to validation and repository organization.
- Solutions Implemented: User defined a numbering standard and requested a simplified project plan.
- Debugging Context: Ongoing discussions about validation workflows and repository rulesets.
- Lessons Learned: Importance of planning for future scalability and validation.
- Progress Tracking:
- Completed Tasks: User defined a numbering standard and provided a list of sample repositories.
- Partially Complete Work: Implementation of the project plan in the README and creation of the validation workflow.
- Validated Outcomes: None yet, as implementation is still in progress.
- Active Work State:
- Current Focus: Adding the project plan to the README file and delegating the validation wo...
Created from VS Code.
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.